package com.xingmang.admin.controller;

import com.xingmang.admin.service.FieldSettingService;
import com.xingmang.common.constant.PageEntity;
import com.xingmang.common.constant.ResultBean;
import com.xingmang.common.dto.admin.FieldSettingInfoDTO;
import com.xingmang.common.dto.admin.FieldSettingPageDTO;
import com.xingmang.common.dto.admin.FieldSettingSaveDTO;
import com.xingmang.common.dto.admin.FieldSettingUpdateDTO;
import com.xingmang.common.vo.admin.FieldSettingPageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @auther: hansom
 * @Version: 1.0
 * @create 2023/6/21 14:19
 */
@RestController
@RequestMapping("/admin/field_setting")
@Api(tags = "常量设置")
public class FieldSettingController {

    @Resource
    private FieldSettingService fieldSettingService;

    @PostMapping("page")
    @ApiOperation("分页")
    public ResultBean<PageEntity<FieldSettingPageVO>> page(@RequestBody @Validated FieldSettingPageDTO dto){
        return fieldSettingService.page(dto);
    }

    @PostMapping("save")
    @ApiOperation("新增")
    public ResultBean save(@RequestBody @Validated FieldSettingSaveDTO dto){
        return fieldSettingService.save(dto);
    }

    @PostMapping("update")
    @ApiOperation("修改")
    public ResultBean update(@RequestBody @Validated FieldSettingUpdateDTO dto){
        return fieldSettingService.update(dto);
    }

    @PostMapping("delete")
    @ApiOperation("删除")
    public ResultBean delete(@RequestBody @Validated FieldSettingInfoDTO dto){
        return fieldSettingService.delete(dto);
    }
}
